﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Dpy.Math
{
    public static class Utility
    {
        public const double Epsilon = 1E-8;

        public static CultureInfo CurrentCulture
        {
            get
            {
                return System.Globalization.CultureInfo.CurrentCulture;
            }
        }

        public static bool EssentiallyEquals(this double a, double b, double epsilon = Utility.Epsilon)
        {
            return System.Math.Abs(a - b) < epsilon;
        }

        public static bool IsZero(this double number, double epsilon = Utility.Epsilon)
        {
            return number.EssentiallyEquals(0, epsilon);
        }

        public static bool IsRealNumber(this double number)
        {
            return !(double.IsNaN(number) || double.IsInfinity(number));
        }        
    }
}
